package ApacheCommons.lang;

import com.google.common.collect.Lists;
import guava.ListsUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.ListUtils;
import org.apache.commons.collections.list.TreeList;
import org.junit.Test;

import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

/**
 * 一个介于ArrayList,与LinkList 之间的list容器
 * 采用LVA树实现
 * @author zhoujie
 * @date 2020-07-31
 */
@Slf4j
public class TreeListTest {

    private int endExclusive;

    @Test
    public void test01(){
        endExclusive = 100000;
        List<Integer> arrayList = IntStream.range(1, endExclusive).boxed().collect(Collectors.toList());
        List<Integer> LinkList = IntStream.range(1, endExclusive).boxed().collect(Collectors.toCollection(LinkedList::new));
        List<Integer> treeList = IntStream.range(1, endExclusive).boxed().collect(Collectors.toCollection(TreeList::new));
        List<Integer> removeList = IntStream.range(1, endExclusive - 10000).boxed().collect(Collectors.toList());

        long startTime = System.currentTimeMillis();
        arrayList.removeAll(removeList);
        log.info("arrayList remove time:[{}] s",(System.currentTimeMillis()-startTime)/1000);

        startTime = System.currentTimeMillis();
        LinkList.removeAll(removeList);
        log.info("LinkList remove time:[{}] s",(System.currentTimeMillis()-startTime)/1000);


        startTime = System.currentTimeMillis();
        treeList.removeAll(removeList);
        log.info("treeList remove time:[{}] s",(System.currentTimeMillis()-startTime)/1000);

    }
}
